package com.boarsoft.boar.sys.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.boarsoft.bean.LogonI;
import com.boarsoft.bean.ReplyInfo;
import com.boarsoft.boar.sys.SysUserFuncBiz;
import com.boarsoft.boar.sys.entity.SysFunc;
import com.boarsoft.common.Authorized;
import com.boarsoft.common.Util;
import com.boarsoft.common.dao.PagedResult;
import com.boarsoft.web.login.Logined;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@RestController
@RequestMapping("/sys/user/func")
public class SysUserFuncAction {
	@Autowired
	private SysUserFuncBiz sysUserFuncBiz;

	/**
	 * 查询指定用户的角色
	 * 
	 * @return
	 */
	@JsonIgnoreProperties({ "roles" })
	@RequestMapping("/list.do")
	@Authorized(code = "sys.user.func.list")
	public ReplyInfo<Object> list(@Logined LogonI<String> logon, String userId, String roleId, String key, String orderBy, int pageNo,
			int pageSize) {
		if (Util.strIsEmpty(userId)) {
			userId = logon.getId();// sysPowerBiz.getUserIdByToken(token);
		}
		PagedResult<SysFunc> pr = sysUserFuncBiz.list(userId, roleId, key, orderBy, pageNo, pageSize);
		return new ReplyInfo<Object>(true, pr);
	}
}